﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Utils;
namespace UI.ModSalesman
{
    public partial class RewardsStatistic : System.Web.UI.Page
    {
        SalesmanBiz salesmanBiz = new SalesmanBiz();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtBtime.Text =  System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd");
                txtEtime.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
            }

        }

        protected void btnSalesman_Click(object sender, EventArgs e)
        {
            string caption = "<b>按售货员统计人数</b><br />";
            gvList.Caption = caption;
           string typeName= ddlType.SelectedValue;
           string bTime = txtBtime.Text.Trim();
           string eTime = txtEtime.Text.Trim();
           gvList.DataSource = salesmanBiz.GetStatisticBySalesmen(typeName, bTime, eTime);
           gvList.DataBind();
        }

        protected void btnEmSearch_Click(object sender, EventArgs e)
        {
            string caption = "<b>按部门统计</b><br />";
            gvList.Caption = caption;           
            string typeName = ddlType.SelectedValue;
            string bTime = txtBtime.Text.Trim();
            string eTime = txtEtime.Text.Trim();
            gvList.DataSource = salesmanBiz.GetStatisticByDept(typeName, bTime, eTime);
            gvList.DataBind();
        }

        //根据gridview打印
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            ToolUtility.Printer("按售货员统计", gvList);
        }        
        protected void btnExcel_Click(object sender, EventArgs e)
        {
            ExcelUtility.GridViewToExcel(gvList, "SalesmenStati.xls");
         }
    }
}